package sg.partying.lcb.android.ui

import android.os.Bundle
import com.salton123.base.ViewBindingActivity
import com.salton123.base.feature.ImmersionFeature
import sg.partying.lcb.android.Session
import sg.partying.lcb.android.databinding.FragmentSelectedBackgroundBinding
import sg.partying.lcb.android.ui.adapter.UltraPagerAdapter
import sg.partying.lcb.api.resp.VirtualType

class SelectBackgroundActivity : ViewBindingActivity<FragmentSelectedBackgroundBinding>() {
    override fun getViewBinding(): FragmentSelectedBackgroundBinding = FragmentSelectedBackgroundBinding.inflate(layoutInflater)
    private var imageList = mutableListOf(
        VirtualType(com.salton123.resources.R.drawable.bg_select_01),
        VirtualType(com.salton123.resources.R.drawable.bg_select_02),
        VirtualType(com.salton123.resources.R.drawable.bg_select_03))
    private val mAdapter by lazy { UltraPagerAdapter() }
    override fun initViewAndData() {
        viewBind.apply {
            viewPager.adapter = mAdapter
            mAdapter.update(imageList)
            viewPager.offscreenPageLimit = imageList.size
            tvLeft.setOnClickListener {
                viewPager.setCurrentItem(viewPager.currentItem - 1, true)
            }
            tvRight.setOnClickListener {
                viewPager.setCurrentItem(viewPager.currentItem + 1, true)
            }
            mAdapter.itemImageClick = { position, item ->
                openActivity(TakePhotoActivity::class.java, Bundle().apply {
                    putInt("index", viewPager.currentItem)
                })
//                finish()
            }
            viewPager.setOnClickListener {
                openActivity(TakePhotoActivity::class.java, Bundle().apply {
                    putInt("index", viewPager.currentItem)
                })
//                finish()
            }
        }
    }

}
